package PTA_7_53;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String[] id = new String[n];
        for (int i = 0; i < n; i++) {
            id[i] = scan.next();
        }
        String[] S = new String[n];
        for (int i = 0; i < n; i++) {
           S[i] = id[i].substring(6,14);
        }
        for (String s:S) {
            System.out.println(s);
        }

        for (String s:S) {

        }

    }
}
